package org.jeecg.talentCooperation.operationLog.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.talentCooperation.common.vo.Result;
import org.jeecg.talentCooperation.operationLog.entity.OperationLog;
import org.jeecg.talentCooperation.operationLog.entity.OperationViewFruitLog;
import org.jeecg.talentCooperation.operationLog.service.IOperationLogService;
import org.jeecg.talentCooperation.operationLog.service.IOperationViewFruitLogService;
import org.jeecg.talentCooperation.talent.entity.TalentBasic;
import org.jeecg.talentCooperation.talent.model.TalentFruitResultModel;
import org.jeecg.talentCooperation.talent.model.TalentResultModel;
import org.jeecg.talentCooperation.talent.service.ITalentBasicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.*;

/**
 * @Description: 人才协作
 * @Author: jeecg-boot
 * @Date:   2023-8-17
 * @Version: V1.0
 */
@RestController
@RequestMapping("/ndTalent/operationLog")
@Slf4j
public class OperationLogController {

	@Autowired
	IOperationLogService operationLogService;
	@Autowired
	IOperationViewFruitLogService operationViewFruitLogService;

	@RequestMapping(value = "/add", method = RequestMethod.POST)
	public Result<OperationLog> add(@RequestBody OperationLog operationLog, HttpServletRequest request) {
		Result<OperationLog> result = new Result<OperationLog>();
		try {
			operationLog.setCreateTime(new Date());
			operationLogService.save(operationLog);
			result.success("添加成功！");
		} catch (Exception e) {
			log.error(e.getMessage(), e);
			result.error500("操作失败");
		}
		return result;
	}

	@RequestMapping(value = "/addViewFruitLog", method = RequestMethod.POST)
	public Result<OperationViewFruitLog> viewFruitLog(@RequestBody OperationViewFruitLog operationLog) {
		Result<OperationViewFruitLog> result = new Result<OperationViewFruitLog>();
		try {
			operationLog.setCreateTime(new Date());
			operationViewFruitLogService.save(operationLog);
			result.success("添加成功！");
		} catch (Exception e) {
			log.error(e.getMessage(), e);
			result.error500("操作失败");
		}
		return result;
	}

}
